home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr50 / qbser310.zip / QBSERIAL.DOC < prev    next >
Text File  |  1993-06-11  |  45KB  |  897 lines

  1.  
  2.  
  3.  
  4.  
  5.                                  QBserial version 3.10
  6.  
  7.             Serial I/O Routines for QB 4.x, BC 7.x, VBDOS, & FOSSIL Drivers
  8.  
  9.           This library will provide you with serial I/O communications
  10.           routines for use in QuickBASIC 4.x (with or without PDQ), the
  11.           Microsoft Basic Compiler 7.x Professional Development System, and
  12.           Visual Basic for DOS 1.x. No longer are you forced to use the poor
  13.           communications support provided by QB.  This program will allow you
  14.           to control 8250 and 16450 type communications ports (UARTS) at
  15.           speeds of up to 115200 baud. Communication ports 1 - 4, and non-
  16.           standard addresses are supported. You will no longer have problems
  17.           with the DTR signal. DTR is left in the same state it was in when
  18.           before you called this driver, or it can be controlled by your
  19.           program. The serial driver includes XON/XOFF and CTS/RTS
  20.           handshaking. Serial input is interrupt driven, using any IRQ you
  21.           specify (1 - 15), with incoming XOFF flow control (if enabled), or
  22.           RTS flow control (if enabled) to prevent overrunning the input
  23.           buffer. This is referred to as "Normal" mode. 
  24.  
  25.           This driver also has a mode where it will operate with FOSSIL
  26.           drivers (INT 14h interface). Using FOSSIL mode allows you to use
  27.           virtually any type of communications hardware, since the type of
  28.           hardware accessed is dependant on the FOSSIL driver. This mode
  29.           requires that you have a FOSSIL driver loaded in advance. This is
  30.           referred to as "FOSSIL" mode.
  31.  
  32.           The driver was written with Microsoft's C, and compiled with
  33.           version 6.0a of that compiler. This driver is useable with
  34.           QuickBASIC version 4.x, and Basic Compiler 6.x & 7.x PDS  (With or
  35.           without PDQ), and Visual Basic for DOS version 1.x. Basic Compiler
  36.           1.x, QuickBASIC 2.x, and 3.x are not supported by this driver. The
  37.           reason is that versions of QuickBASIC prior to 4.0 do not support
  38.           the extensive multi-language interface that QB4.x has (via the
  39.           DECLARE statement and Microsoft language extensions). Throughout
  40.           this manual QB will be used to refer to both QuickBASIC, the Basic
  41.           Compilers (6.x & 7.x PDS), and Visual Basic for DOS.
  42.  
  43.           Before the driver can be used, the following INCLUDE statement must
  44.           be added to the beginning of your QB program:
  45.  
  46.           '    $INCLUDE: 'qbserial.dec'
  47.  
  48.           The declarations included by this statement specify all the entry
  49.           points into the serial driver. DO NOT change them or the driver
  50.           will not function.
  51.  
  52.           Refer to the included sample programs SIMPLE.BAS, PCBDOOR.BAS, and
  53.           OFFHOOK.BAS. they use most of the calls described below.
  54.  
  55.  
  56.  
  57.         QBSERIAL User Manual - V 3.10                              Page 1
  58.  
  59.  
  60.  
  61.  
  62.           Qbserial has two (2) modes of operation: Normal and FOSSIL. The
  63.           mode you operate in is specified in the OpenComm statement (The
  64.           FOS% parameter). In the following sections, where applicable, each
  65.           parameter will be explained as to how it operates in both Normal
  66.           and FOSSIL mode.
  67.  
  68.                                   Port Initialization
  69.  
  70.           OpenComm Port%, IRQ/Stat%, Wordlen%, Parity%, Baudrate&, HS%, FOS%
  71.  
  72.           Parameter:     Port%
  73.  
  74.           Normal:   If the specified port is 1 to 4, the driver opens that
  75.                     port. If you specify the port as ZERO (0) the driver
  76.                     enters "LOCAL" mode. This allows you to call the driver
  77.                     with data, but the driver won't send anything. This is
  78.                     useful when working with "doors". if you specify the port
  79.                     as any other value, QBserial will use that as the base
  80.                     address for the port. This allows you to work with non-
  81.                     standard I/O addresses. Note however that if you open a
  82.                     non-standard port, you must specify an IRQ value from 1
  83.                     to 15 - There is no default IRQ when used in this manner.
  84.  
  85.           FOSSIL:   Unlike normal mode, "port" does not necessarily relate to
  86.                     a specific communications port or address. Using a "1"
  87.                     for a port value does NOT necessarily mean COM1. Also
  88.                     unlike QBserial's normal mode, a value other than 1 - 4
  89.                     does NOT refer to a base address of a UART.
  90.  
  91.                     When using FOSSIL mode, "port" refers to a logical
  92.                     device. Port 0 is the first port of a FOSSIL device
  93.                     driver, Port 1 the second, and so on. When used with
  94.                     drivers such as X00.SYS (assuming you didn't remap the
  95.                     ports), port 0 refers to COM1, and port 1 refers to COM2.
  96.                     This will vary depending on the FOSSIL driver used and
  97.                     the device(s) referenced. In most cases it is determined
  98.                     when the FOSSIL driver is installed through some sort of
  99.                     configuration file (or command line options) that relates
  100.                     the physical devices to logical port numbers. However, in
  101.                     order to make the FOSSIL implementation as compatible as
  102.                     possible with "normal" mode, the port number passed will
  103.                     have a value of ONE (1) subtracted from it before
  104.                     referring to the actual FOSSIL port. Therefore to access
  105.                     the first port (port 0), you pass a 1 as you did with in
  106.                     normal mode. Internally, one (1) is subtracted so that
  107.                     port 0 is referenced. This makes the implementation or
  108.                     normal and FOSSIL modes totally transparent.
  109.  
  110.                     Specifying a value of ZERO (0) for the port puts the
  111.                     driver in "local" mode. This is identical to normal mode.
  112.  
  113.         QBSERIAL User Manual - V 3.10                              Page 2
  114.  
  115.  
  116.  
  117.  
  118.           Parameter:     IRQ/Stat%
  119.  
  120.           Normal:   Specifies which interrupt to use with this port. If the
  121.                     value of IRQ% is ZERO (0), then the default IRQ values
  122.                     are used (COM1 & COM3 use IRQ4, COM2 & COM4 use IRQ3).
  123.                     This is what most applications will use. Specify an IRQ
  124.                     value of 1 through 15 when you want to use an IRQ value
  125.                     other than the default. Such as when you want to use
  126.                     IRQ15 with COM3. NOTE: Be careful when choosing an IRQ
  127.                     value other than the default. Most machines use some of
  128.                     the other IRQ inputs for other machine functions such as
  129.                     the Hard drive and system clock. QBserial DOES NOT chain
  130.                     the interrupt, it takes it over entirely. If you choose
  131.                     an IRQ that is used for something already, your machine
  132.                     will most certainly operate improperly.
  133.  
  134.           FOSSIL:   No IRQ value is necessary in FOSSIL mode since all
  135.                     communications tasks are handled outside of QBserial. The
  136.                     IRQ used with a particular "port" will be determined at
  137.                     the time the FOSSIL driver is installed, probably through
  138.                     the same configuration method mentioned above.
  139.  
  140.                     When using FOSSIL mode, this field is now Status. This is
  141.                     a value RETURNED to the programmer when OpenComm has
  142.                     completed. It indicates whether or not the FOSSIL driver
  143.                     initialized properly and is ready to perform
  144.                     communications tasks. A value of 1954h (HEX) or 6484
  145.                     (DECIMAL) indicates a successful initialization. ANY
  146.                     OTHER value indicates a initialization failure. You
  147.                     should terminate your program and inform the user of your
  148.                     program of the problem. Failures could result from the
  149.                     FOSSIL driver not being installed, or not installed
  150.                     properly. If you pass an invalid baud rate (see below),
  151.                     Status will be returned as a ZERO. Otherwise Status will
  152.                     be the actual value returned from the FOSSIL driver in
  153.                     response to initialization. These values other than
  154.                     1954h/6484 may offer a clue as to why the driver did not
  155.                     initialize. These "possible" values would be documented
  156.                     in the documentation for the FOSSIL driver.
  157.  
  158.           Parameter:     Wordlen%
  159.  
  160.                     An integer specifying the word length of the serial data.
  161.                     It has a value of 7 or 8. Identical in both modes.
  162.  
  163.           Parameter:     Parity%
  164.  
  165.                     An integer, 0 = NONE, 1 = ODD, 2 = EVEN. Identical in
  166.                     both modes.
  167.  
  168.  
  169.         QBSERIAL User Manual - V 3.10                              Page 3
  170.  
  171.  
  172.           Parameter:     BaudRate&
  173.  
  174.           Normal:   This is a LONG INTEGER representing the desired baud
  175.                     rate. Valid numbers are 0, 300, 1200, 2400, 4800, 9600,
  176.                     19200, 38400, 57600, and 115200. The value you send is
  177.                     NOT checked and I assume you could generate crazy baud
  178.                     rates if desired. 115200 is the absolute maximum rate
  179.                     that can be generated. If you specify a baud rate of ZERO
  180.                     then the serial port is used AS-IS. The rate, word
  181.                     length, & parity are NOT changed. This is useful for door
  182.                     operation since the port is already initialized at the
  183.                     proper settings when you get control.
  184.  
  185.           FOSSIL:   Identical to normal mode with the exception being that
  186.                     the range of selectable baudrates is limited. This is
  187.                     limited by the current FOSSIL specification. The valid
  188.                     baud rates are: 0, 300, 1200, 2400, 4800, 9600, 19200,
  189.                     and 38400. If you pass a value other than one of these
  190.                     valid rates, the driver will not initialize and return a
  191.                     ZERO for status. In FOSSIL mode, if you specify a baud
  192.                     rate of ZERO (0), the Baudrate initialization call is not
  193.                     performed by OpenComm. This *SHOULD* have the same effect
  194.                     that normal mode does by not changing the baudrate, word
  195.                     length, & parity. However, since this is an undefined
  196.                     condition in the FOSSIL specification, there is no way of
  197.                     guaranteeing that the current settings will not be
  198.                     changed during initialization of the driver. If you want
  199.                     a 100% guarantee of the rate setting, you should provide
  200.                     a speed when you do an OpenComm. This is only being done
  201.                     for compatibility with Normal mode.
  202.  
  203.           Parameter:     HS%
  204.  
  205.                     An integer specifying the type of handshake you wish to
  206.                     use between the CPU and Modem (or destination device).
  207.                     Valid numbers are: 0 = NO handshake, 1 = XON/XOFF, 2 =
  208.                     CTS/RTS, 3 = XON/XOFF and CTS/RTS. Identical in both
  209.                     modes.
  210.  
  211.           Parameter:     FOS%
  212.  
  213.                     An integer that specifies which mode the driver will
  214.                     operate in. Zero (0) specifies "Normal" mode, and One (1)
  215.                     specifies "FOSSIL" mode.
  216.  
  217.  
  218.                                      Serial Output
  219.  
  220.           To send a string of data out the serial port, you use the
  221.           "Transmit" call as follows:
  222.  
  223.                Temp$ = "Transmit this..."
  224.  
  225.         QBSERIAL User Manual - V 3.10                              Page 4
  226.  
  227.  
  228.                Transmit Temp$
  229.  
  230.                     or
  231.  
  232.                Transmit "Send this also...."
  233.  
  234.           If you want to transmit single characters, you can use the
  235.           "WriteChar" function. Transmit calls WriteChar to send the actual
  236.           characters to the port. If you wish to use WriteChar, it has the
  237.           following format:
  238.  
  239.                Status% = WriteChar(Char%)
  240.  
  241.           Char% is the integer value of the character you want to send, it is
  242.           not a string. Status% is an integer returned by WriteChar, it is
  243.           NON-ZERO if the character was actually sent to the port, and ZERO
  244.           if the character was not sent. WriteChar will loop indefinitely on
  245.           CTS hold, XOFF hold, or Transmit Buffer Busy. These loops will exit
  246.           if carrier is lost in FULL or PARTIAL modes and return a ZERO
  247.           status% (This occurs in normal mode ONLY. What happens in FOSSIL
  248.           mode is undefined). WriteChar gives you more low level control of
  249.           the sending of characters, but you must send each character
  250.           separately and monitor its status.
  251.  
  252.           The Transmit function monitors the status of its calls to WriteChar
  253.           and triggers QuickBASIC's User Event trap (UEVENT) if a carrier
  254.           loss occurs in FULL mode. The UEVENT trap (FULL mode) is used by
  255.           default. You can disable the use of this event trap in the event
  256.           you already use the UEVENT trap for something else (PARTIAL mode).
  257.           Therefore, by default, carrier loss detection in your program is
  258.           done with the ON UEVENT GOSUB/UEVENT ON statements. The example
  259.           programs show the use of this method. By default UEVENT is also
  260.           used for catching carrier loss on keyboard input. this is described
  261.           below.
  262.  
  263.  
  264.  
  265.                                       Serial Input
  266.  
  267.           Serial input is managed with three functions: DataWaiting,
  268.           ReadChar, & ClearInputBuffer. DataWaiting is used to test the input
  269.           buffer to see if any characters need to be read from it. ReadChar
  270.           is then called to get the characters. ClearInputBuffer flushes the
  271.           input buffer of any existing characters. Both example programs
  272.           contain a subroutine called "KeyboardInput" that demonstrates the
  273.           use of these calls. It also properly handles input from the local
  274.           and remote keyboards, and can be the routine you use in your
  275.           programs if you wish. Basically the procedure for reading the
  276.           remote keyboard (serial input) is as follows:
  277.  
  278.  
  279.  
  280.  
  281.         QBSERIAL User Manual - V 3.10                              Page 5
  282.  
  283.  
  284.                IF DataWaiting THEN
  285.                     C$ = CHR$(ReadChar)
  286.                END IF
  287.  
  288.           The DataWaiting function also monitors the state of the carrier
  289.           detect signal and triggers, in FULL mode, the user event trap
  290.           (UEVENT) if carrier is lost. As you can see a singular trap routine
  291.           catches carrier loss on output as well as input. You will notice
  292.           that the "KeyboardInput" subroutine (in SIMPLE.BAS) loops using
  293.           DataWaiting, and as such, carrier is constantly checked while
  294.           waiting for input. If the ReadChar function is called when no data
  295.           is available (as indicated by DataWaiting) a NULL character is
  296.           returned.
  297.  
  298.           In "Normal" mode, if XOFF/XON, CTS/RTS, or BOTH is enabled, then
  299.           the serial buffer will be protected from overfills. When the buffer
  300.           reaches 75% of capacity, an XOFF will be sent on the serial output
  301.           or RTS will be dropped. When the buffer empties out to 25% of
  302.           capacity, an XON will be sent or RTS raised. The capacity of the
  303.           input buffer is 2048 bytes. In FOSSIL mode, the threshold points
  304.           where flow control occurs and the buffer size, are determined by
  305.           the FOSSIL driver.
  306.  
  307.  
  308.                                  Carrier Detect Control
  309.  
  310.           There are three modes of carrier detection: Full, Partial, & None.
  311.           Each has it own distinct use for a particular purpose. The driver
  312.           defaults to FULL carrier detection unless you change it. The
  313.           following call is used to change control modes:
  314.  
  315.                CarrierDetect 0 [or] 1 [or] 2
  316.  
  317.           Specifying a TWO (2) sets carrier detection to FULL. This is the
  318.           default mode. When a loss of carrier occurs while transmitting,
  319.           polling for input data, or sitting in a wait loop (XOFF/XON or
  320.           CTS), the driver will return to the calling program and trip the
  321.           UEVENT flag. Tripping the UEVENT flag causes Basic to go to the
  322.           User Event trap routine (providing ON UEVENT GOSUB/UEVENT ON has
  323.           been set up in the user program). You should use this mode only if
  324.           you want to use the UEVENT trap for carrier loss detection. You
  325.           cannot transmit data (with the Transmit function) in this mode if
  326.           there is no carrier. You can send characters in this mode with the
  327.           WriteChar function.
  328.  
  329.           Specifying a ONE (1) sets carrier detection to PARTIAL. This mode
  330.           is similar to FULL with the exception that the UEVENT flag is not
  331.           tripped when carrier is lost. This mode should be used if UEVENT is
  332.           used for something else in your program, or you don't wish to
  333.           utilize UEVENT.
  334.  
  335.  
  336.  
  337.         QBSERIAL User Manual - V 3.10                              Page 6
  338.  
  339.  
  340.           Specifying a ZERO (0) sets carrier detection to NONE. An example of
  341.           this mode would be where "plain Jane" serial I/O is required (such
  342.           as communicating with a "dumb" terminal). In this application there
  343.           are no modem handshake signals (3 wire EIA/RS-232). This mode can
  344.           also be used for talking to a modem when there is no carrier signal
  345.           present (such as dialing and initialization commands). The Transmit
  346.           and WriteChar routines will always transmit data in this mode with
  347.           or without carrier present. Carrier detection must be disabled in
  348.           this mode to prevent calls to Uevent and disable the no carrier
  349.           escape mechanisms built into the XON/XOFF loops. Important: If you
  350.           are using "Normal" mode, and you are using the XOFF/XON protocol,
  351.           with "CarrierDetect 0" set, and receive an XOFF while transmitting,
  352.           you will sit forever waiting for an XON. This is a normal
  353.           condition, with the exception that there is no escape from this
  354.           loop other than XON. If you are using "FOSSIL" mode, this action is
  355.           undefined.
  356.  
  357.  
  358.                            Carrier Loss Detection by Polling
  359.  
  360.           As mentioned above, by default, the UEVENT trap is used to detect
  361.           when a loss of carrier occurs. There is also a function that allows
  362.           you to detect loss of carrier without using the UEVENT trap. While
  363.           I feel that using UEVENT is the simplest way to catch a carrier
  364.           loss in a program, it is possible that UEVENT might need to be used
  365.           by something else. This function is:
  366.  
  367.                X% = CarrierLost
  368.  
  369.           This function call allows to you to 'poll' for the state of
  370.           carrier. CarrierLost returns a NON-ZERO value when there is NO
  371.           carrier, and a ZERO when there IS carrier. CarrierLost is a real
  372.           time function, it returns the current carrier condition at the time
  373.           of the call. This allows you to code simple IF or DO loops to
  374.           detect loss:
  375.  
  376.                IF CarrierLost THEN
  377.                     ..process carrier loss
  378.                END IF
  379.  
  380.  
  381.                                       Modem Status
  382.  
  383.           NOTE:     This function ONLY works in Normal mode. It has no
  384.                     functional equivalent in FOSSIL mode.
  385.  
  386.           The Modem Status register contains bits that convey information
  387.           about the Modem's current state, and what has happened since the
  388.           last status query. In most instances these bits will not be needed
  389.  
  390.  
  391.  
  392.  
  393.         QBSERIAL User Manual - V 3.10                              Page 7
  394.  
  395.  
  396.           for normal serial operations. This was added to provide additional
  397.           information about the device in use.
  398.  
  399.           Normal Mode:
  400.  
  401.                Modem Status Register:
  402.  
  403.               7       6       5       4       3       2       1       0   Bit
  404.           ┌───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
  405.           │  128  │  64   │  32   │  16   │   8   │   4   │   2   │   1   │
  406.           │Carrier│ Ring  │DataSet│ Clear │ Delta │ Delta │ Delta │ Delta │
  407.           │Detect │Signal │ Ready │To Send│  CD   │  RI   │  DSR  │  CTS  │
  408.           └───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘
  409.  
  410.           Bits 0 - 3 of this register report a change in the state of their  
  411.           respective RS-232 (signal) pins. A "1" in any of these bits means
  412.           that it's input has changed since last status read. Reading this
  413.           register clears bits 0 - 3. Bits 4 - 7 report the absolute state of
  414.           their respective RS-232 inputs (These bits are "real time").
  415.  
  416.           To use this function, the Basic statement would be:
  417.  
  418.                value% = ModemStatus
  419.  
  420.           The value returned by ModemStatus depends on the particular bit(s)
  421.           set in the Modem Status register. The corresponding decimal weights
  422.           are listed in the boxes in the above figure. As an example, if you
  423.           were monitoring the register and looking for a Ring Indication, you
  424.           would be looking for a value of 64. NOTE: If you are looking for a
  425.           particular value, you must AND the value you wish to test against
  426.           what ModemStatus returns. So, if you were looking for a Ring
  427.           Indication, you would use:
  428.  
  429.                St% = ModemStatus
  430.                if St% AND 64 then
  431.                     ... Ring detected
  432.  
  433.  
  434.                                                                            
  435.                                   Program Termination                      
  436.  
  437.           Since "OpenComm" seizes an interrupt vector, this vector needs to
  438.           be restored BEFORE your program ends. If you neglect to restore
  439.           this vector, you could be risking a crash. The routine used to
  440.           reset the vector is: CloseComm. Only use CloseComm if you specified
  441.           a port value in the OpenComm call (Normal or FOSSIL modes). If you
  442.           specified a port value of ZERO (Local mode) the interrupt vector is
  443.           NOT grabbed, and does not need to be reset. In Normal mode,
  444.           CloseComm resets any UART registers to their original value. In
  445.           FOSSIL mode, how the UART registers are left is undefined.
  446.  
  447.  
  448.  
  449.         QBSERIAL User Manual - V 3.10                              Page 8
  450.  
  451.  
  452.  
  453.                                Data Terminal Ready (DTR)
  454.  
  455.           Everybody that has used QuickBASIC's OPEN COMn statement is very
  456.           familiar with the problems of the DTR signal. Apparently Microsoft
  457.           felt that DTR would never be needed after a program terminates.
  458.           Anybody who has ever tried to write a door, or chain from one
  459.           program to another has cursed this decision at some time during
  460.           their programs development. This driver handles the DTR with a
  461.           different view. When you close the comm channel the DTR signal is
  462.           left in the same state it was when you opened the comm channel. For
  463.           door applications, this is a must. 
  464.  
  465.           A function call is provided however that allows your program to
  466.           control the DTR signal:
  467.  
  468.           DTRcontrol 1 [or] 0           ' 0 = DTR OFF, 1 = DTR ON
  469.  
  470.           Additionally when you use DTRcontrol to change the state of the DTR
  471.           signal it also instructs the driver to leave it this way when the
  472.           CloseComm function is called. Remember that the driver leaves DTR
  473.           the way it found it when OpenComm was called. If you used some
  474.           other method to change DTR after OpenComm was called, it would
  475.           automatically return to that original state when you called
  476.           CloseComm. Therefor only DTRcontrol should be used if you wish to
  477.           change the state of DTR. This appears to operate identically in
  478.           normal and FOSSIL modes.
  479.  
  480.  
  481.                                  Request To Send (RTS)
  482.  
  483.           NOTE:     This function ONLY works in Normal mode. It has no
  484.                     functional equivalent in FOSSIL mode.
  485.  
  486.           Request To Send (RTS) is a hardware flow control signal used to
  487.           tell the remote device to STOP sending data to us. Normally RTS is
  488.           set "on" and data will always flow (or the signal is ignored at the
  489.           remote end). With some communications programs RTS is used to
  490.           temporarily stop a modem from sending data while I/O is done to a
  491.           slow disk. This is especially true with high speed communications
  492.           where there is very little time between interrupts. This function
  493.           is independent of the automatic RTS flow control selected by
  494.           handshake 2 or 3 which tells the remote device to stop sending when
  495.           the input buffer is almost full. This function allows you to
  496.           manually control the state of RTS so you could, for instance, go
  497.           off and write the data somewhere without fear of loosing data.
  498.  
  499.           RTScontrol 1 [or] 0           ' 0 = RTS OFF, 1 = RTS ON
  500.  
  501.           When you use RTScontrol to change the state of the RTS signal it
  502.           also instructs the driver to leave it this way when the CloseComm
  503.           function is called. The driver leaves RTS the way it found it when
  504.  
  505.         QBSERIAL User Manual - V 3.10                              Page 9
  506.  
  507.  
  508.           OpenComm was called. If you used some other method to change RTS
  509.           after OpenComm was called, it will automatically return to that
  510.           original state when you call CloseComm. Therefor only RTScontrol
  511.           should be used if you wish to change the state of RTS. This is
  512.           similar in the way DTRcontrol works.
  513.  
  514.                               Driver Version and Copyright
  515.  
  516.           A function is available to access the drivers version and copyright
  517.           string. This would be used if you wish to display in your final
  518.           product the version of QBserial that your are using, and/or my
  519.           copyright along with yours. In order to access the copyright
  520.           string, the following lines should be added to your Basic program:
  521.  
  522.                     X& = DriverCopyright
  523.                     WHILE (PEEK(X&))
  524.                          CP$ = CP$ + CHR$(PEEK(X&))
  525.                          X& = X& + 1
  526.                     WEND
  527.  
  528.           This places the version/copyright string into string variable CP$.
  529.           This string may now be handled in whatever method you choose.
  530.  
  531.  
  532.                                  Crescent's PDQ Library
  533.  
  534.           An object module for use with PDQ is also included. PDQ does not
  535.           support UEVENT, so all references to UEVENT in the text should be
  536.           ignored. You will need to do carrier checking by polling with the
  537.           CarrierLost function. If you use FULL mode and carrier is lost it
  538.           will operate the same way as PARTIAL mode. The only exception to
  539.           this is the Transmit function, which when in FULL or PARTIAL mode,
  540.           will not transmit data.
  541.  
  542.  
  543.  
  544.                                         Linking
  545.  
  546.           Since object modules are provided for QB4.x, BC7, VBDOS, and PDQ,
  547.           you will need to select the proper one to use for your program. The
  548.           file QBSER.OBJ should be used for programs compiled with
  549.           QuickBASIC. BC7SER.OBJ is to be used for programs compiled with BC7
  550.           PDS, and Visual Basic for DOS. QBSERPDQ.OBJ is for PDQ users.
  551.           Typical link command lines would look like this: (Please note that
  552.           your command lines will probably be different if you use additional
  553.           libraries to generate your code). The term "yourprog" is meant to
  554.           imply any code modules necessary for linking your project. This
  555.           could one .OBJ file, or many. Please note that compiling any
  556.           linking projects from within the QB/QBX/VBDOS development
  557.           environment(s) is not supported.
  558.  
  559.  
  560.  
  561.         QBSERIAL User Manual - V 3.10                             Page 10
  562.  
  563.  
  564.           Link yourprog qbser;               (For QuickBASIC)
  565.  
  566.           Link yourprog bc7ser;              (For BC7 PDS and Visual Basic)
  567.  
  568.           Link yourprog qbserpdq acrtused;   (For PDQ)
  569.                                     ^
  570.                                     └──── See note about acrtused.obj
  571.  
  572.           NOTE:     In the past the file ACRTUSED.OBJ was required to be
  573.                     linked in when using the PDQ replacement libraries. This
  574.                     was necessary to satisfy a dummy external call. It
  575.                     appears that it may no longer be necessary to link with
  576.                     this file anymore. You should try linking without
  577.                     acrtused, and see if a link error occurs. If no error
  578.                     occurs, then you do not need to specify it.
  579.  
  580.  
  581.  
  582.                                     Quick Libraries
  583.  
  584.           If you wish to develop programs from within the environment, you
  585.           will first need to create a Quick library using one of the object
  586.           modules QBSER.OBJ, BC7SER.OBJ, or QBSERPDQ.OBJ. To create a Quick
  587.           lib for QuickBASIC 4.x, use the following Link command:
  588.  
  589.                Link QBSER,,,BQLB4x/q
  590.  
  591.           Where "BQLB4x" is one of the following: BQLB40.LIB, BQLB41.LIB, or
  592.           BQLB45.LIB. Use the one that came with your compiler. If you use
  593.           the wrong BQLB file you might get an "Invalid Format" error when
  594.           attempting to start QuickBASIC. QBSER.OBJ may also be added to
  595.           Quick Libraries containing other routines and OBJ's as well.
  596.  
  597.           To create a Quick Library for use within QBX (BC7's environment)
  598.           use the following link command (IMPORTANT: be sure to use Link
  599.           v5.xx that came with BC7 or you will receive linking errors):
  600.  
  601.                Link BC7SER,,,QBXQLB/q;
  602.  
  603.           To create a Quick Library for use within Visual Basic's environment
  604.           (VBDOS) use the following link command (IMPORTANT: be sure to use
  605.           Linker that came with VBDOS or you will receive linking errors):
  606.  
  607.                Link BC7SER,,,VBDOSQLB/q;
  608.  
  609.           For PDQ, use the method for QB4.x, since you will be using the
  610.           built in run time routines built into the environment. You ONLY use
  611.           QBSERPDQ.OBJ when you link the EXEcutable file.
  612.  
  613.           Remember too, that you can also add BC7SER.OBJ to Quicklibs
  614.           containing other routines.
  615.  
  616.  
  617.         QBSERIAL User Manual - V 3.10                             Page 11
  618.  
  619.  
  620.                                      Specifications
  621.  
  622.           The following port addresses and default interrupts are used in
  623.           Normal mode:
  624.  
  625.                Comm      Base Address        IRQ (Default)
  626.  
  627.                 1          3F8 hex            4
  628.                 2          2F8 hex            3
  629.                 3          3E8 hex            4
  630.                 4          2E8 hex            3
  631.  
  632.           Please read the section explaining the OpenComm function for
  633.           information on how to use addresses or IRQ's other than the
  634.           defaults.
  635.  
  636.  
  637.                                 Registration and Support
  638.  
  639.           QBserial is distributed as shareware. You may copy and distribute
  640.           it freely, as long as you do NOT modify it or add (or remove) any
  641.           files to it.
  642.  
  643.           QBserial is not free software, and requires registration. There are
  644.           two classes of registration which are dependant upon use:
  645.           Commercial and Non-Commercial.
  646.  
  647.           Registration of QBserial is $25 for non-commercial use. Non-
  648.           commercial uses are: Personal use, or use in another shareware
  649.           product such as doors and utilities where you allows others to try
  650.           the product first before buying and request a nominal registration
  651.           fee. Source code is available as an option for an additional $50.
  652.  
  653.           Registration of QBserial for commercial use is $75. Commercial uses
  654.           are: Inclusion of QBserial into ANY product that is to be sold for
  655.           profit, or any use of this program in a business environment. Any
  656.           program that must be paid for in advance before the product is
  657.           delivered, or use in a corporate environment fits this category.
  658.           Commercial registration includes the source code for QBserial in C
  659.           (Microsoft C), if desired.
  660.  
  661.           Please register your copy!
  662.  
  663.           Software and Shareware distribution houses may charge a nominal
  664.           distribution and copying fee not to exceed $5.00. They may not sell
  665.           this program outright or ask you for the registration fee directly,
  666.           they must tell you that registration is required by the author.
  667.  
  668.           If you have access to a BBS that is an ILINK network member, you
  669.           can reach me in the respective Basic conferences. If you do not
  670.           have ILINK access anywhere nearby, then you can always contact me
  671.           on the SailBoard BBS at the number listed below. I would prefer if
  672.  
  673.         QBSERIAL User Manual - V 3.10                             Page 12
  674.  
  675.  
  676.           you contact me directly on the SailBoard however, as mail networks
  677.           aren't always as reliable as I'd like, and I have missed messages.
  678.           I'll do the best I can to help if you have questions. Bugs will be
  679.           tended to if required, and good suggestions tend to be implemented.
  680.  
  681.  
  682.                                       Source Code
  683.  
  684.           The source code for QBserial is available. The source is available
  685.           by signing at the appropriate place on the registration form. The
  686.           source may be used for you own internal uses only. The source may
  687.           not be distributed by you to any other person, even if you make
  688.           changes to it. Nor can the resulting object code be sold or
  689.           distributed. Modifications can only be used in your end product,
  690.           and without any type of royalty. The source is available only after
  691.           you register QBserial. The license fee for the QBserial source code
  692.           is $50.00 for Non-Commercial users. Commercial users receive the
  693.           source as part of their registration fee if they desire it.
  694.  
  695.                                       Jeff Sumberg
  696.                                Sysop of the SailBoard BBS
  697.                                Ringwood, NJ, 201-831-8152
  698.  
  699.                                         [ or ]
  700.  
  701.                                         Box 212
  702.                                   Ringwood, NJ, 07456
  703.  
  704.  
  705.  
  706.                                     Acknowledgments
  707.  
  708.           Thanks go out to Mark "Sparky" Herring for using these routines in
  709.           his highly successful Qmail door.
  710.  
  711.           Thanks to Brent Yandell for using these routines in his PCBoard
  712.           File Viewer PCBFV and PCBFX programs.
  713.  
  714.           Thanks to Mark Wilson for some very good ideas in version 2.0.
  715.           Thanks to Michael Conley for finding a real time sensitive
  716.           interrupt problem and for providing very useful information.
  717.           Thanks to Jeffrey Morley (author of ZipLab) for testing.
  718.  
  719.  
  720.                                Distribution File Contents
  721.  
  722.            QBSER.OBJ     QBserial object module for use with QuickBASIC
  723.                          version 4.x.
  724.  
  725.            QBSERPDQ.OBJ  QBserial object module for use with PDQ and
  726.                          QuickBASIC 4.x or PDQ with Basic Compiler 7.x (NEAR
  727.                          string model).
  728.  
  729.         QBSERIAL User Manual - V 3.10                             Page 13
  730.  
  731.  
  732.  
  733.            BC7SER.OBJ    QBserial object module for use with Basic Compiler
  734.                          6.x, Basic Compiler 7.x (NEAR or FAR string models),
  735.                          and Visual Basic for DOS.
  736.  
  737.            ACRTUSED.OBJ  Dummy object module to satisfy an external reference
  738.                          when linking with PDQ files. May no longer be
  739.                          necessary. See Text.
  740.  
  741.            OFFHOOK.BAS   Sample Basic program. Used to take modem off hook.
  742.                          References PCBoard data files for port info. Can
  743.                          also be used stand alone.
  744.  
  745.            PCBDOOR.BAS   Very simple frame for creating a door in PCBoard.
  746.                          Should be used ONLY as a guide.
  747.  
  748.            SIMPLE.BAS    Very simple "do nothing" program offering examples
  749.                          of how to call QBserial functions.
  750.  
  751.            QBSERIAL.DEC  Function declarations for QBserial.
  752.  
  753.            QBSERIAL.DOC  QBserial Documentation (this file).
  754.  
  755.            READ.ME       Latest changes to QBserial.
  756.  
  757.            REGISTER.FRM  QBserial Registration form. Please Register your
  758.                          copy.
  759.  
  760.            FILE_ID.DIZ
  761.            DESC.SDI      BBS description files.
  762.  
  763.  
  764.                                  Changes and Revisions
  765.  
  766.           06/09/89  1.0  Initial Release
  767.  
  768.           06/21/89  1.1  Added carrier detection control. Calling program can
  769.                          turn detection off and on as desired. Necessary if
  770.                          data sending/receiving required if carrier isn't
  771.                          present.
  772.  
  773.           09/01/89  1.2  Fixed a bug in Readchar where 'extended' characters
  774.                          (ASCII 128 to 255) were causing an Illegal Function
  775.                          Call in the CHR$() conversion (because they were
  776.                          being returned as negative numbers). Extended
  777.                          character may now be received properly. Added three
  778.                          new functions: CDtrap, CarrierLost, and DTRcontrol.
  779.  
  780.  
  781.           03/24/90  1.5  Added support for Basic Compiler 7.0 PDS and PDQ.
  782.                          Added sections to manual about Linking, Source code
  783.                          availability, and updated section on Quicklibs.
  784.  
  785.         QBSERIAL User Manual - V 3.10                             Page 14
  786.  
  787.  
  788.                          Separate object files now supplied for QB, BC7, and
  789.                          PDQ.
  790.  
  791.           05/01/90  1.6  Oops! PDQ users found out fast that I forgot to
  792.                          compile the PDQ module with stack checking removed.
  793.                          I also forgot to include ACRTUSED.OBJ to satisfy
  794.                          linking requirements. Sorry 'bout that! Released
  795.                          only as beta to those that needed it.
  796.  
  797.           11/01/90  2.0  Added capability to specify non-standard port
  798.                          addresses and which IRQ to use when the port is
  799.                          opened. Removed CDtrap function. Created new carrier
  800.                          detection modes using the CarrierDetect function. (0
  801.                          = NONE, 1 = PARTIAL, 2 = FULL). Also added
  802.                          DriverCopyright function to allow program access to
  803.                          the driver version.
  804.  
  805.           02/08/92  2.10 Added RTS flow control support. RTS will be used to
  806.                          control data coming in to QBserial when the
  807.                          handshake is set to 2 (CTS/RTS). Removed necessity
  808.                          for SERIAL.LIB library file by adding inline
  809.                          assembler that performed the routines that were
  810.                          previously included in that library. QBserial is now
  811.                          compiled with Microsoft C 6.0 which will give
  812.                          smaller, faster, and more efficient code than QuickC
  813.                          could generate. This is especially true in the
  814.                          interrupt area. Added new function RTScontrol, to
  815.                          allow program to control RTS line directly.
  816.                          Increased size of input buffer from 1024 to 2048
  817.                          bytes. Changed method in which interrupt controller
  818.                          mask bits were set & cleared. Corrected error found
  819.                          in documentation describing the function of
  820.                          CarrierDetect.
  821.  
  822.           06/20/92  2.20 Added support for extended IRQs. QBserial now
  823.                          supports IRQ 8 - 15. Added a new sample program to
  824.                          the QBserial distribution package (OFFHOOK.BAS) to
  825.                          demonstrate usage of QBserial.
  826.  
  827.           07/05/92  2.25 While experimenting with some programs of my own I
  828.                          found a some errors in the disabling of the IRQ
  829.                          masks on the Interrupt Controller when exiting from
  830.                          QBserial. The program has been changed so that if
  831.                          the IRQ you specify is already turned ON when
  832.                          OpenComm executes, QBserial will leave it ON when
  833.                          you do a CloseComm. In versions since 2.10, the IRQ
  834.                          mask was always turned OFF when CloseComm was
  835.                          executed. This caused other communications programs
  836.                          such as BBS's that don't reset the port when
  837.                          returning from QBserial to appear to "lock up" when
  838.                          they regained control.
  839.  
  840.  
  841.         QBSERIAL User Manual - V 3.10                             Page 15
  842.  
  843.  
  844.           11/01/92  3.00 Added the ability for QBserial to use FOSSIL
  845.                          drivers. Modified the OpenComm call to allow the
  846.                          programmer to specify which mode to operate in. The
  847.                          QBSERIAL.DEC file has changed and the one provided
  848.                          with this version MUST be used when upgrading to
  849.                          this version. Added new function: ModemStatus, to
  850.                          read the Modem Status register of the UART. This is
  851.                          a normal mode function only.
  852.  
  853.           06/12/93  3.10 This version is a bug fix version. Several minor
  854.                          errors and omissions have been reported by users,
  855.                          and these have been corrected in this version. These
  856.                          include:
  857.                          - Modified the QBSERIAL.DEC file to allow Qbserial
  858.                          to work with Visual Basic for DOS. This is because
  859.                          of an unknown, undocumented change in the way
  860.                          DECLARE works in Visual Basic for DOS.
  861.                          - ClearInputBuffer did not work in FOSSIL mode.
  862.                          - Modified OpenComm to reset flow control flags,
  863.                          buffer pointers, etc. It was found that if a port
  864.                          was opened, used, closed, then opened again without
  865.                          program termination or chain from program to
  866.                          program, that the Flow Control mode would be wrong
  867.                          or inoperative. The input buffer also was not
  868.                          flushed when a port was opened. This was because
  869.                          initialization to these flags and pointers was only
  870.                          being done when the EXE was loaded, not during
  871.                          OpenComm. These are done within OpenComm.
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.         QBSERIAL User Manual - V 3.10                             Page 16